#!/bin/bash
export GONOPROXY=""
export GO111MODULE=on
export GOPROXY=https://cmc.centralrepo.rnd.huawei.com/cbu-go
export GONOSUMDB=*
export GOSUMB=off

PROJECT_ROOT=$(cd `dirname $0/`/..;pwd)

cd $PROJECT_ROOT/code/src
go mod tidy

CGO_CFLAGS="-fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2" go build -buildmode=pie --ldflags "-s -linkmode 'external' -extldflags '-Wl,-z,now'" main.go
cd $PROJECT_ROOT
tar -czvf $PROJECT_ROOT/huaweicloud-dwr-sdk-demo-custom-go-${CID_BUILD_TIME}.tar.gz .codelabs code introduction
